package com.chenhy.server.utils;

import com.chenhy.server.pojo.Admin;
import org.springframework.security.core.context.SecurityContextHolder;

public class SecurityUtil {

    public static Admin getCurrentAdmin(){
        return ((Admin) SecurityContextHolder.getContext().getAuthentication().getPrincipal());
    }

    public static String getCurrentAdminUsername(){
        return getCurrentAdmin().getUsername();
    }

    public static Integer getCurrentAdminId(){
        return getCurrentAdmin().getId();
    }

}
